package fr.labri.macchiato.framework.business.encoder;

import fr.labri.macchiato.framework.business.model.businessEntity.BusinessEntity;
import fr.labri.macchiato.framework.business.model.preferences.UserPreferences;
import fr.labri.macchiato.framework.business.model.product.Model;
import fr.labri.macchiato.framework.business.model.product.Offer;
import fr.labri.macchiato.framework.business.model.project.Project;
import fr.labri.macchiato.framework.technical.encoder.Encoder;

/**
 * Singleton for all the classes implementing the {@link Encoder} interface
 * 
 * @author Matthieu FOUCAULT
 * 
 */
public class Encoders {

	private static Encoders instance;
	private Encoder<UserPreferences> preferencesEncoder;
	private Encoder<Project> projectEncoder;
	private Encoder<Offer> offerEncoder;
	private Encoder<Model> modelEncoder;
	private Encoder<BusinessEntity> businessEntityEncoder;

	private Encoders() {
		preferencesEncoder = new PreferencesEncoder();
		projectEncoder = new ProjectEncoder();
		offerEncoder = new OfferEncoder();
		modelEncoder = new ModelEncoder();
		businessEntityEncoder = new BusinessEntityEncoder();
	}

	/**
	 * @return an encoder for a {@link Project} object
	 */
	public Encoder<Project> getProjectEncoder() {
		return projectEncoder;
	}

	/**
	 * @return the singleton instance
	 */
	public static Encoders getInstance() {
		if (instance == null)
			instance = new Encoders();
		return instance;
	}

	/**
	 * @return an encoder for a {@link UserPreferences} object
	 */
	public Encoder<UserPreferences> getPreferencesEncoder() {
		return preferencesEncoder;
	}

	/**
	 * @return an encoder for an {@link Offer}
	 */
	public Encoder<Offer> getOfferEncoder() {

		return offerEncoder;
	}

	/**
	 * @return an encoder for a {@link Model}
	 */
	public Encoder<Model> getModelEncoder() {
		return modelEncoder;
	}
	
	/**
	 * 
	 * @return an encoder for a {@link BusinessEntity}
	 */
	public Encoder<BusinessEntity> getBusinessEntityEncoder(){
		return businessEntityEncoder;
	}

}
